package exercise6;

import java.util.Scanner;

public class Exercise13_01 {
    public static void main(String []args){


        Scanner input=new Scanner(System.in);
        System.out.println("请输入三角形的三条边：");
        double side1 = input.nextDouble();
        double side2 = input.nextDouble();
        double side3 = input.nextDouble();
        Triangle my_triangle=new Triangle(side1,side2,side3);

        my_triangle.setColor("red");


        my_triangle.setFilled(true);

        System.out.println(my_triangle.toString());
        System.out.println("三角形的颜色是："+my_triangle.getColor());
        System.out.println("三角形的面积是"+my_triangle.getArea());
        System.out.println("三角形的周长是"+my_triangle.getPerimeter());

    }
}

class Triangle extends GeometricObject{
    double side1;
    double side2;
    double side3;

    public Triangle(){
    }

    public Triangle(double side1,double side2,double side3){
        this.side1=side1;
        this.side2=side2;
        this.side3=side3;
    }

    public double getSide1() {
        return side1;
    }

    public double getSide2() {
        return side2;
    }

    public double getSide3() {
        return side3;
    }

    public double getArea(){
        double s = (side1 + side2 + side3) / 2;
        return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
    }

    public double getPerimeter(){
        return side1+side3+side2;
    }

    @Override
    public String toString(){
        return "Triangle: side1 = " + side1 + " side2 = " + side2 +
                " side3 = " + side3;
    }
}
